<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8"/>
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <title>活动管理-活动信息</title>

    <link href="../plugin/bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="../plugin/bootstrap-table-1.11.1/bootstrap-table.min.css" rel="stylesheet"/>
    <link href="../plugin/sweetalert-6.6.2/sweetalert2.min.css" rel="stylesheet"/>
    <link href="../plugin/bootstrap-3.3.7/plugin/file_input/fileinput.min.css" rel="stylesheet"/>
    <link href="../plugin/bootstrap-3.3.7/plugin/datatimepicker/bootstrap-datetimepicker.min.css" rel="stylesheet"/>
    <link href="../plugin/jquery-zoomify/zoomify.min.css" rel="stylesheet"/>

    <script src="../plugin/jquery-3.2.1/jquery-3.2.1.min.js"></script>
    <script src="../plugin/bootstrap-3.3.7/js/bootstrap.min.js"></script>
    <script src="../plugin/bootstrap-3.3.7/plugin/file_input/fileinput.min.js"></script>
    <script src="../plugin/bootstrap-3.3.7/plugin/file_input/local_zh.js"></script>
    <script src="../plugin/bootstrap-3.3.7/plugin/datatimepicker/bootstrap-datetimepicker.min.js"></script>
    <script src="../plugin/bootstrap-3.3.7/plugin/datatimepicker/bootstrap-datetimepicker.zh-CN.js"></script>
    <script src="../plugin/bootstrap-table-1.11.1/bootstrap-table.min.js"></script>
    <script src="../plugin/bootstrap-table-1.11.1/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="../plugin/sweetalert-6.6.2/sweetalert2.min.js"></script>
    <script src="../plugin/jquery-3.2.1/jquery.formautofill.min.js"></script>
    <script src="../plugin/jquery-3.2.1/jquery.serializejson.js"></script>
    <script src="../plugin/wangEditor-3.0.15/wangEditor.min.js"></script>
    <script src="../plugin/jquery-zoomify/zoomify.min.js"></script>
    <script src="../plugin/soul/utils3.js"></script>
    <script src='../base/base.js'></script>

</head>

<body>

<div class="modal fade" data-backdrop="static" id="activity_modal_edit_chinese_detail">
    <div class="modal-dialog modal-lg ">
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" data-dismiss="modal">
                    <span>&times;</span>
                </button>
                <h4 class="modal-title">
                    <b>活动详情(中文)</b>
                </h4>
            </div>
            <div class="modal-body">
                <div id="activity_modal_edit_chinese_detail_editor"></div>
            </div>
            <div class="modal-footer">
                <button class="btn btn-default" data-dismiss="modal">取消</button>
                <button class="btn btn-primary" onclick="activity.chinese.save()">保存</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" data-backdrop="static" id="activity_modal_edit_english_detail">
    <div class="modal-dialog modal-lg ">
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" data-dismiss="modal">
                    <span>&times;</span>
                </button>
                <h4 class="modal-title">
                    <b>活动详情(英文)</b>
                </h4>
            </div>
            <div class="modal-body">
                <div id="activity_modal_edit_english_detail_editor"></div>
            </div>
            <div class="modal-footer">
                <button class="btn btn-default" data-dismiss="modal">取消</button>
                <button class="btn btn-primary" onclick="activity.english.save()">保存</button>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        var resp = AjaxUtil.isLogin();
        if (!resp) return;

        var module = 'activity';
        var query = [{
            id: 'chineseName',
            type: 'text',
            name: '活动名称(中文)',
            paramName: 'chineseName',
            palceholder: ''
        },{
            id: 'englishName',
            type: 'text',
            name: '活动名称(英文)',
            paramName: 'englishName',
            palceholder: ''
        }, {
            id: 'status',
            type: 'select',
            name: '活动状态',
            paramName: 'status',
            items: [{
                name: '未开始',
                value: '1'
            }, {
                name: '进行中',
                value: '2'
            }, {
                name: '活动结束',
                value: '3'
            }]
        }];
        var toolbar = {
            default: [false, true, true, true],// back;add;edit;remove
            dialog: [60, 2, 9],//对话框参数:模态框宽度(百分比);表单标题宽度;表单输入框宽度
            extra: [{
                name: '活动详情(中文)',
                glyphicon: 'list',
                onclick: 'showChineseDetail',
            }, {
                name: '活动详情(英文)',
                glyphicon: 'list',
                onclick: 'showEnglishDetail',
            }]
        };
        // 表单内容配置
        var formElement = [{
            action: [false, true],
            type: 'hidden', // 表单类型
            name: 'activityId', // 字段名称
        }, {
            action: [true, true],
            id: 'startDateTime',
            type: 'datetime',
            label: '活动开始时间',
            name: 'startDateTime',
        }, {
            action: [true, true],
            id: 'endDateTime',
            type: 'datetime',
            label: '活动结束时间',
            name: 'endDateTime',
        }, {
            action: [true, true],
            type: 'text',
            label: '活动名称(中文)',
            name: 'chineseName',
        }, {
            action: [true, true],
            type: 'text',
            label: '活动简介(中文)',
            name: 'chineseIntroduce',
        }, {
            action: [true, true],
            id: 'chinesePhoto',
            type: 'images',
            label: '活动图片(中文)',
            name: 'chinesePhoto',
            module: 'chinesePhoto',
            maxCount: 1
        }, {
            action: [true, true],
            id: 'chineseBigPhoto',
            type: 'images',
            label: '活动大图(中文)',
            name: 'chineseBigPhoto',
            module: 'chineseBigPhoto',
            maxCount: 1
        }, {
            action: [true, true],
            type: 'text',
            label: '活动名称(英文)',
            name: 'englishName',
        }, {
            action: [true, true],
            type: 'text',
            label: '活动简介（英文）',
            name: 'englishIntroduce',
        }, {
            action: [true, true],
            id: 'englishPhoto',
            type: 'images',
            label: '活动图片(英文)',
            name: 'englishPhoto',
            module: 'englishPhoto',
            maxCount: 1
        }, {
            action: [true, true],
            id: 'englishBigPhoto',
            type: 'images',
            label: '活动大图(英文)',
            name: 'englishBigPhoto',
            module: 'englishBigPhoto',
            maxCount: 1
        }];


        var bootstrapTable = {
            columns: [{
                radio: true
            }, {
                field: 'activityId',
                title: '活动编号',
            }, {
                field: 'chineseName',
                title: '活动名称(中文)',
            }, {
                field: 'chinesePhoto',
                title: '活动图片(中文)',
                formatter: function (value, row, index) {
                    return BootstrapTableUtil.formatter.image(value, 'chinesePhoto', '60')
                },
            }, {
                field: 'chineseBigPhoto',
                title: '活动大图(中文)',
                formatter: function (value, row, index) {
                    return BootstrapTableUtil.formatter.image(value, 'chineseBigPhoto', '60')
                },
            }, {
                field: 'englishName',
                title: '活动名称(英文)',
            }, {
                field: 'englishPhoto',
                title: '活动图片(英文)',
                formatter: function (value, row, index) {
                    return BootstrapTableUtil.formatter.image(value, 'englishPhoto', '60')
                },
            }, {
                field: 'englishBigPhoto',
                title: '活动大图(英文)',
                formatter: function (value, row, index) {
                    return BootstrapTableUtil.formatter.image(value, 'englishBigPhoto', '60')
                },
            }, {
                field: 'startDateTime',
                title: '开始时间',
                formatter: BootstrapTableUtil.formatter.datetime
            }, {
                field: 'endDateTime',
                title: '结束时间',
                formatter: BootstrapTableUtil.formatter.datetime
            }, {
                field: 'status',
                title: '活动状态',
                formatter: function (value, row, index) {
                    if (value == 1) {
                        return '未生效';
                    } else if (value == 2) {
                        return '进行中';
                    } else if (value == 3) {
                        return '活动结束';
                    }
                }
            }]
        };
        activity = SingleTablePageCreateUtil.createInstance(module, query, toolbar, formElement, bootstrapTable);
        activity.onEditModalShowBefore = function (row) {
            FileinputUtil.initPreview("#activity_form_edit_chinesePhoto", "chinesePhoto", row.chinesePhoto);
            FileinputUtil.initPreview("#activity_form_edit_englishPhoto", "englishPhoto", row.englishPhoto);
            FileinputUtil.initPreview("#activity_form_edit_chineseBigPhoto", "chineseBigPhoto", row.chineseBigPhoto);
            FileinputUtil.initPreview("#activity_form_edit_englishBigPhoto", "englishBigPhoto", row.englishBigPhoto);
            row.startDateTime = FormatUtil.formatDateTime(row.startDateTime);
            row.endDateTime = FormatUtil.formatDateTime(row.endDateTime);
            row.createDate = FormatUtil.formatDateTime(row.createDate);
            return row;
        };
        activity.onRemoveSubmitBefore = function (row) {
            row.startDateTime = FormatUtil.formatDateTime(row.startDateTime);
            row.endDateTime = FormatUtil.formatDateTime(row.endDateTime);
            row.createDate = FormatUtil.formatDateTime(row.createDate);
            return row;
        };

        //显示中文活动详情
        activity.showChineseDetail = function () {
            var row = TablePageCreatePublicUtil.getRowFromTable('#activity_table');
            if (!row) return false;
            activity.chinese.currentId = row.activityId;
            editor.txt.html(row.chineseDetail || '');
            $('.w-e-text-container').css('height', '500px')
            $('#activity_modal_edit_chinese_detail').modal('show');
        };

        activity.chinese = {};
        activity.chinese.currentId = undefined;
        activity.chinese.save = function () {
            var detail = editor.txt.html();
            console.log(detail);
            var resp = AjaxUtil.postJson('activity/edit_chinese_detail', {
                activityId: activity.chinese.currentId,
                chineseDetail: detail
            });
            if (resp) {
                SwalUtil.success(resp.msg);
                $('#activity_table').bootstrapTable('refresh');
                $('#activity_modal_edit_chinese_detail').modal('hide');
                editor.txt.html('');
            }

        };

        //显示英文活动详情
        activity.showEnglishDetail = function () {
            var row = TablePageCreatePublicUtil.getRowFromTable('#activity_table');
            if (!row) return false;
            activity.english.currentId = row.activityId;
            editor1.txt.html(row.englishDetail || '');
            $('.w-e-text-container').css('height', '500px')
            $('#activity_modal_edit_english_detail').modal('show');
        };

        activity.english = {};
        activity.english.currentId = undefined;
        activity.english.save = function () {
            var detail = editor1.txt.html();
            console.log(detail);
            var resp = AjaxUtil.postJson('activity/edit_english_detail', {
                activityId: activity.english.currentId,
                englishDetail: detail
            });
            if (resp) {
                SwalUtil.success(resp.msg);
                $('#activity_table').bootstrapTable('refresh');
                $('#activity_modal_edit_english_detail').modal('hide');
                editor1.txt.html('');
            }

        };
        
        var E = window.wangEditor;
        var editor = new E('#activity_modal_edit_chinese_detail_editor');
        editor.customConfig.uploadImgServer = 'wangEditor/uploadImages?token=' + BaseConfig.token;
        editor.customConfig.uploadFileName = 'file';
        // editor.customConfig.uploadImgMaxLength = 1;
        editor.customConfig.uploadImgTimeout = 3 * 60 * 1000;
        editor.create();

        var editor1 = new E('#activity_modal_edit_english_detail_editor');
        editor1.customConfig.uploadImgServer = 'wangEditor/uploadImages?token=' + BaseConfig.token;
        editor1.customConfig.uploadFileName = 'file';
        // editor.customConfig.uploadImgMaxLength = 1;
        editor1.customConfig.uploadImgTimeout = 3 * 60 * 1000;
        editor1.create();


    });
</script>
</body>

</html>